package com.crecheng.shop.Manage;

import com.crecheng.shop.DAO.AddressData;
import com.crecheng.shop.util.ConSQL;

import java.util.List;

public final class AddressManage {
    public static List<AddressData> getAll(){
        return ConSQL.select(AddressData.class);
    }

    public static List<AddressData> get(String other){
        return ConSQL.select(AddressData.class,other);
    }

    public static AddressData get(int id){
        var d=get("id="+id);
        return d.size()>0?d.get(0):null;
    }

    public static List<AddressData> getByUid(int uid){
        return get("uid="+uid);
    }

    public static boolean del(int id){
        return ConSQL.delete(AddressData.class,"id="+id)>0;
    }

    public static boolean delByUid(int uid){
        return ConSQL.delete(AddressData.class,"uid="+uid)>0;
    }

    public static boolean del(AddressData d){
        return del(d.getId());
    }

    public static boolean add(AddressData d){
        return ConSQL.insert(AddressData.class,d)>0;
    }

    public static boolean update(AddressData d){
        return ConSQL.update(AddressData.class,d.key(),d)>0;
    }

}
